/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.uniminuto.Videominuto.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author JULIAN
 */
@Entity
@Table(name = "video")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Video.findAll", query = "SELECT v FROM Video v"),
    @NamedQuery(name = "Video.findByIsanVideo", query = "SELECT v FROM Video v WHERE v.isanVideo = :isanVideo"),
    @NamedQuery(name = "Video.findByTitulo", query = "SELECT v FROM Video v WHERE v.titulo = :titulo"),
    @NamedQuery(name = "Video.findByAnoReproduccion", query = "SELECT v FROM Video v WHERE v.anoReproduccion = :anoReproduccion"),
    @NamedQuery(name = "Video.findByDuracion", query = "SELECT v FROM Video v WHERE v.duracion = :duracion"),
    @NamedQuery(name = "Video.findByCalificacionMedia", query = "SELECT v FROM Video v WHERE v.calificacionMedia = :calificacionMedia"),
    @NamedQuery(name = "Video.findByPrecioAlquiler", query = "SELECT v FROM Video v WHERE v.precioAlquiler = :precioAlquiler"),
    @NamedQuery(name = "Video.findByPrecioCompra", query = "SELECT v FROM Video v WHERE v.precioCompra = :precioCompra")})
public class Video implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "isan_video")
    private Integer isanVideo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "titulo")
    private String titulo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ano_reproduccion")
    @Temporal(TemporalType.DATE)
    private Date anoReproduccion;
    @Basic(optional = false)
    @NotNull
    @Column(name = "duracion")
    private int duracion;
    @Basic(optional = false)
    @NotNull
    @Column(name = "calificacion_media")
    private int calificacionMedia;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "precio_alquiler")
    private BigDecimal precioAlquiler;
    @Basic(optional = false)
    @NotNull
    @Column(name = "precio_compra")
    private BigDecimal precioCompra;
    @JoinTable(name = "video_doblaje", joinColumns = {
        @JoinColumn(name = "isan_vdi", referencedColumnName = "isan_video")}, inverseJoinColumns = {
        @JoinColumn(name = "id_doblaje_lengua", referencedColumnName = "id_lenguaje")})
    @ManyToMany
    private List<Idioma> idiomaList;
    @ManyToMany(mappedBy = "videoList")
    private List<Serie> serieList;
    @ManyToMany(mappedBy = "videoList")
    private List<Coleccion> coleccionList;
    @ManyToMany(mappedBy = "videoList")
    private List<Compra> compraList;
    @ManyToMany(mappedBy = "videoList")
    private List<Categoria> categoriaList;
    @ManyToMany(mappedBy = "videoList")
    private List<Alquiler> alquilerList;
    @JoinTable(name = "video_subtitulado", joinColumns = {
        @JoinColumn(name = "isan_vdi", referencedColumnName = "isan_video")}, inverseJoinColumns = {
        @JoinColumn(name = "id_subti_lenguaje", referencedColumnName = "id_lenguaje")})
    @ManyToMany
    private List<Idioma> idiomaList1;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "video")
    private List<Historial> historialList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "video")
    private List<ClienteCalificacionVideo> clienteCalificacionVideoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "video")
    private List<PersonaVideo> personaVideoList;
    @JoinColumn(name = "id_tipo_video", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private TipoVideo idTipoVideo;
    @JoinColumn(name = "id_idioma_original", referencedColumnName = "id_lenguaje")
    @ManyToOne(optional = false)
    private Idioma idIdiomaOriginal;
    @JoinColumn(name = "id_clasificacion", referencedColumnName = "id_clasificacion")
    @ManyToOne(optional = false)
    private Clasificacion idClasificacion;

    public Video() {
    }

    public Video(Integer isanVideo) {
        this.isanVideo = isanVideo;
    }

    public Video(Integer isanVideo, String titulo, Date anoReproduccion, int duracion, int calificacionMedia, BigDecimal precioAlquiler, BigDecimal precioCompra) {
        this.isanVideo = isanVideo;
        this.titulo = titulo;
        this.anoReproduccion = anoReproduccion;
        this.duracion = duracion;
        this.calificacionMedia = calificacionMedia;
        this.precioAlquiler = precioAlquiler;
        this.precioCompra = precioCompra;
    }

    public Integer getIsanVideo() {
        return isanVideo;
    }

    public void setIsanVideo(Integer isanVideo) {
        this.isanVideo = isanVideo;
    }

    public String getTitulo() {
        return titulo;
    }

    public void setTitulo(String titulo) {
        this.titulo = titulo;
    }

    public Date getAnoReproduccion() {
        return anoReproduccion;
    }

    public void setAnoReproduccion(Date anoReproduccion) {
        this.anoReproduccion = anoReproduccion;
    }

    public int getDuracion() {
        return duracion;
    }

    public void setDuracion(int duracion) {
        this.duracion = duracion;
    }

    public int getCalificacionMedia() {
        return calificacionMedia;
    }

    public void setCalificacionMedia(int calificacionMedia) {
        this.calificacionMedia = calificacionMedia;
    }

    public BigDecimal getPrecioAlquiler() {
        return precioAlquiler;
    }

    public void setPrecioAlquiler(BigDecimal precioAlquiler) {
        this.precioAlquiler = precioAlquiler;
    }

    public BigDecimal getPrecioCompra() {
        return precioCompra;
    }

    public void setPrecioCompra(BigDecimal precioCompra) {
        this.precioCompra = precioCompra;
    }

    @XmlTransient
    public List<Idioma> getIdiomaList() {
        return idiomaList;
    }

    public void setIdiomaList(List<Idioma> idiomaList) {
        this.idiomaList = idiomaList;
    }

    @XmlTransient
    public List<Serie> getSerieList() {
        return serieList;
    }

    public void setSerieList(List<Serie> serieList) {
        this.serieList = serieList;
    }

    @XmlTransient
    public List<Coleccion> getColeccionList() {
        return coleccionList;
    }

    public void setColeccionList(List<Coleccion> coleccionList) {
        this.coleccionList = coleccionList;
    }

    @XmlTransient
    public List<Compra> getCompraList() {
        return compraList;
    }

    public void setCompraList(List<Compra> compraList) {
        this.compraList = compraList;
    }

    @XmlTransient
    public List<Categoria> getCategoriaList() {
        return categoriaList;
    }

    public void setCategoriaList(List<Categoria> categoriaList) {
        this.categoriaList = categoriaList;
    }

    @XmlTransient
    public List<Alquiler> getAlquilerList() {
        return alquilerList;
    }

    public void setAlquilerList(List<Alquiler> alquilerList) {
        this.alquilerList = alquilerList;
    }

    @XmlTransient
    public List<Idioma> getIdiomaList1() {
        return idiomaList1;
    }

    public void setIdiomaList1(List<Idioma> idiomaList1) {
        this.idiomaList1 = idiomaList1;
    }

    @XmlTransient
    public List<Historial> getHistorialList() {
        return historialList;
    }

    public void setHistorialList(List<Historial> historialList) {
        this.historialList = historialList;
    }

    @XmlTransient
    public List<ClienteCalificacionVideo> getClienteCalificacionVideoList() {
        return clienteCalificacionVideoList;
    }

    public void setClienteCalificacionVideoList(List<ClienteCalificacionVideo> clienteCalificacionVideoList) {
        this.clienteCalificacionVideoList = clienteCalificacionVideoList;
    }

    @XmlTransient
    public List<PersonaVideo> getPersonaVideoList() {
        return personaVideoList;
    }

    public void setPersonaVideoList(List<PersonaVideo> personaVideoList) {
        this.personaVideoList = personaVideoList;
    }

    public TipoVideo getIdTipoVideo() {
        return idTipoVideo;
    }

    public void setIdTipoVideo(TipoVideo idTipoVideo) {
        this.idTipoVideo = idTipoVideo;
    }

    public Idioma getIdIdiomaOriginal() {
        return idIdiomaOriginal;
    }

    public void setIdIdiomaOriginal(Idioma idIdiomaOriginal) {
        this.idIdiomaOriginal = idIdiomaOriginal;
    }

    public Clasificacion getIdClasificacion() {
        return idClasificacion;
    }

    public void setIdClasificacion(Clasificacion idClasificacion) {
        this.idClasificacion = idClasificacion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (isanVideo != null ? isanVideo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Video)) {
            return false;
        }
        Video other = (Video) object;
        if ((this.isanVideo == null && other.isanVideo != null) || (this.isanVideo != null && !this.isanVideo.equals(other.isanVideo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.edu.uniminuto.Videominuto.entities.Video[ isanVideo=" + isanVideo + " ]";
    }
    
}
